define(['jquery', 'bootstrap', 'select2', 'validate', 'validate.en', 'koala-search' , 'modalSearch'],
function($, validate) {
  return {
    
    init: function() {
      this.initQuery();
    },
    
    initQuery: function() {
       	
       	$(document).find('form').bind('reset', function(e){
            $(this).find(".select2").select2("val", "");
       	})
       	
        $(document).find('form').bt_validate();
        $('select[name="companyIds"]').select2({
            theme: "classic",
            placeholder : '请选择',
            minimumResultsForSearch : -1,
            allowClear : true,
          });
        
        $('select[name="dutyId"]').select2({
            placeholder : '请选择',
            minimumResultsForSearch : -1,
            allowClear : true,
          });
          
        $('select[name="disabled"]').select2({
             placeholder : '请选择',
             minimumResultsForSearch : -1,
             allowClear : true,
           });
        
        
        $('[data-target="#modal-search-vehicle"]').modalsearch({
        	url: function(){
                var url = window.__CTX__.root + '/vehicles/query';
                return url + "?companyIds=" + $("select[name='companyIds']").val();
             },
            tableColumns: ['驳运车代码', '驳运车名称'],
            tableValues: ['code', 'name'],
            displayValues: ['code', 'name'],
            values: ['id']
          });
        
        var options = {
          time: 1000,
          url: window.__CTX__.root + "/vehicles/query",
          queryName: "code",
          value: ["id"],
          display: ["code", "name"]
        }
        
        $('.vehicle-search').koalaSearch(options);
        
        
        $(document).on("koala.search.value.changed", ".vehicle-search", function(){
          console.log($(this).next().val());
          // TODO 其他查询后的逻辑
        })
      }
    //add 
    
  }
})